package com.zzt.zt_gson;

import androidx.appcompat.app.AppCompatActivity;

import android.nfc.Tag;
import android.os.Bundle;
import android.util.Log;

import com.alibaba.fastjson.JSON;
import com.google.gson.Gson;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = "Gson main";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initData();
    }

    private void initData() {
        CopyOrderObjWrite aaa = new CopyOrderObjWrite();
        aaa.setReason("");
        aaa.setAvatarPic("https://oss.xtrendspeed.com");
        aaa.setCode(null);
        aaa.setRealTimeProfitLoss("2.5");
        aaa.setOrderId("37088934");
        aaa.setBuy("1.18662");
        aaa.setUuid("B172246910393CE3");
        aaa.setProductName("GBPUSD");
        aaa.setNumber("");
        aaa.setLevelNum(0);
        aaa.setPrice("1.18712");
        aaa.setId(215995);
        aaa.setIsCopy(0);
        aaa.setUnitPrice("40");
        aaa.setMargin("0.004");
        aaa.setProductId("GBPUSD40V2");
        aaa.setNickName("Runer");
        aaa.setSell("1.18658");
        aaa.setCopyCount(14);
        aaa.setCurrentPrice("1.18662");
        aaa.setVipType(1);
        aaa.setWeight("5000");
        aaa.setWeekProfit("92.74");
        aaa.setUnit("英镑");
        aaa.setCreateTime(1668576517000L);
        aaa.setBuyType("1");

        List<CopyOrderObjWrite> bbb = new ArrayList<>();
        bbb.add(aaa);

        HttpResponse<List<CopyOrderObjWrite>> ccc = new HttpResponse<>();
        ccc.setData(bbb);

        Gson gson = new Gson();
        String dddJson = gson.toJson(ccc);
        Log.w(TAG, dddJson);


        String fastJson = JSON.toJSONString(ccc);
        Log.i(TAG, "fastJson:" + fastJson);

//        dddJson = "{\"data\":[{\"reason\":\"\",\"avatarPic\":\"https://oss.xtrendspeed.\",\"code\":null,\"realTimeProfitLoss\":\"2.5\",\"orderId\":37088934,\"buy\":\"1.18662\",\"uuid\":\"B172246910393CE3\",\"point\":100,\"productName\":\"GBPUSD\",\"number\":1,\"levelNum\":0,\"price\":\"1.18712\",\"id\":215995,\"isCopy\":0,\"productType\":1,\"unitPrice\":\"40\",\"margin\":\"0.004\",\"productId\":\"GBPUSD40V2\",\"nickName\":\"Runer\",\"sell\":\"1.18658\",\"copyCount\":14,\"currentPrice\":\"1.18662\",\"vipType\":1,\"weight\":\"5000\",\"weekProfit\":92.74,\"unit\":\"英镑\",\"createTime\":1668576517000,\"buyType\":1},{\"reason\":\"\",\"avatarPic\":\"https://oss.xtrendspeed.com/images/avatar/0c9c8b2e-a319-44cb-9c0c-fd75ed4df786.jpg/avatar_100\",\"code\":\"EURUSD\",\"realTimeProfitLoss\":\"0.12\",\"orderId\":37088928,\"buy\":\"1.03723\",\"uuid\":\"B172246910393CE3\",\"point\":100,\"productName\":\"EURUSD\",\"number\":1,\"levelNum\":0,\"price\":\"1.03725\",\"id\":215994,\"isCopy\":0,\"productType\":1,\"unitPrice\":\"40\",\"margin\":\"0.004\",\"productId\":\"EURUSD40V2\",\"nickName\":\"Runer\",\"sell\":\"1.03721\",\"copyCount\":7,\"currentPrice\":\"1.03723\",\"vipType\":1,\"weight\":\"6000\",\"weekProfit\":92.74,\"unit\":\"欧元\",\"createTime\":1668576509000,\"buyType\":1},{\"reason\":\"\",\"avatarPic\":\"https://oss.xtrendspeed.com/images/avatar/e5ef8de3-1d1b-4657-93d2-f64b03b58041.jpg/avatar_100\",\"code\":\"USOIL\",\"realTimeProfitLoss\":\"4.75\",\"orderId\":37084846,\"buy\":\"85.680\",\"uuid\":\"D7BEA23052E0BBCA\",\"point\":100,\"productName\":\"USOIL\",\"number\":1,\"levelNum\":0,\"price\":\"85.870\",\"id\":215802,\"isCopy\":0,\"productType\":4,\"unitPrice\":\"40\",\"margin\":\"0.004\",\"productId\":\"USOIL40V3\",\"nickName\":\"Sade\",\"sell\":\"85.650\",\"copyCount\":5,\"currentPrice\":\"85.680\",\"vipType\":1,\"weight\":\"25\",\"weekProfit\":69.55,\"unit\":\"桶\",\"createTime\":1668564749000,\"buyType\":1},{\"reason\":\"\",\"avatarPic\":\"https://oss.xtrendspeed.com/images/avatar/db18cdf7-c962-479e-a1ac-888356694ba9.png/avatar_100\",\"code\":\"NZDUSD\",\"realTimeProfitLoss\":\"33.1\",\"orderId\":37042680,\"buy\":\"0.61601\",\"uuid\":\"73BB0E4DCEF20330\",\"point\":100,\"productName\":\"NZDUSD\",\"number\":1,\"levelNum\":5,\"price\":\"0.61268\",\"id\":214777,\"isCopy\":0,\"productType\":1,\"unitPrice\":\"40\",\"margin\":\"0.004\",\"productId\":\"NZDUSD40\",\"nickName\":\"Morrison\",\"sell\":\"0.61599\",\"copyCount\":189,\"currentPrice\":\"0.61599\",\"vipType\":4,\"weight\":\"10000\",\"weekProfit\":34.05,\"unit\":\"纽元\",\"createTime\":1668495716000,\"buyType\":2},{\"reason\":\"\",\"avatarPic\":\"https://oss.xtrendspeed.com/images/avatar/0c9c8b2e-a319-44cb-9c0c-fd75ed4df786.jpg/avatar_100\",\"code\":\"HK0144\",\"realTimeProfitLoss\":\"4.792\",\"orderId\":37042075,\"buy\":\"11.05\",\"uuid\":\"B172246910393CE3\",\"point\":100,\"productName\":\"HK0144\",\"number\":1,\"levelNum\":0,\"price\":\"10.85\",\"id\":214763,\"isCopy\":0,\"productType\":6,\"unitPrice\":\"40\",\"margin\":\"0.004\",\"productId\":\"HK0144_40\",\"nickName\":\"Runer\",\"sell\":\"11.00\",\"copyCount\":20,\"currentPrice\":\"11.00\",\"vipType\":1,\"weight\":\"250\",\"weekProfit\":92.74,\"unit\":\"股\",\"createTime\":1668494401000,\"buyType\":2}],\"success\":true,\"errorCode\":\"\",\"errorInfo\":\"\",\"pagerManager\":null}";
        Log.v(TAG, dddJson);
        HttpCallback<List<CopyOrderObj>> httpCallback = new HttpCallback<List<CopyOrderObj>>() {
            @Override
            public void onResponse(HttpResponse<List<CopyOrderObj>> response) {
                Log.d(TAG, response.getData().toString());
            }
        };
        httpCallback.onResponse(dddJson);
    }
}